<!-- ========================================= CONTENT ========================================= -->
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use frontend\models\Address;
use yii\widgets\DetailView;

//$cartTotal = $this->params['cartTotal'];
//$cartList = $this->params['cartList'];
?>
<section id="checkout-page">
	<div class="container">
		<div class="col-xs-12 no-margin">
			<section id="shipping-address">
				<h2 class="border h1">你的地址</h2>
				<form >
					<div class="row field-row">
						<div class="col-xs-12">	
							<?=
							DetailView::widget([
//								'template' => '<tr><th{captionOptions}>{label}</th><td{contentOptions}>{value}</td></tr>',
//        'captionOptions'=>'width:100px',
								'model' => $addressModel,
								'attributes' => [
									'firstname',
									'lastname',
									'address',
									'telephone']
							])
							?>
						</div>
					</div><!-- /.field-row -->
				</form>
			</section><!-- /#shipping-address -->


			<section id="your-order">
				<h2 class="border h1">你的订单</h2>
				<form id="orderList" method="post" action="<?php echo yii\helpers\Url::toRoute('shop-order/create'); ?>">
					<?php
					foreach ($orderDetailList as $key => $orderDetailUnit) {
						?>
						<div class="row no-margin order-item">
							<div class="col-xs-12 col-sm-1 no-margin">
								<a href="#" class="qty"><?php echo $orderDetailUnit['productnum'] ?> x</a>
							</div>
							<div class="col-xs-12 col-sm-1 no-margin">
								<a href="#" class="thumb-holder">
									<img class="lazy" alt="" src="//<?php echo $productList[$orderDetailUnit->detailId]['cover'] ?>" />
								</a>
							</div>
							<div class="col-xs-12 col-sm-1 no-margin">

							</div>
							<div class="col-xs-12 col-sm-6 ">
								<div class="title"><a href="#"><?php echo $productList[$orderDetailUnit->detailId]['title'] ?> </a></div>
								<div class="brand">热卖</div>
							</div>

							<div class="col-xs-12 col-sm-2 no-margin">
								<div class="price"><?php echo $orderDetailUnit['productnum'] * $orderDetailUnit['price'] ?></div>
							</div>
						</div><!-- /.order-item -->
					<?php } ?>
				</form>
			</section><!-- /#your-order -->

			<div id="total-area" class="row no-margin">
				<div class="col-xs-12 col-lg-4 col-lg-offset-8 no-margin-right">
					<div id="subtotal-holder">
						<ul class="tabled-data inverse-bold no-border">
							<li>
								<label>订单总价</label>
								<div class="value "><?php echo $model->amount ?></div>
							</li>
							<li>
								<label>运费选择</label>
								<div class="value">
									<div class="radio-group">
										<!--<input class="le-radio" type="radio" name="group1" value="free">--> 
										<div class="radio-label bold">包邮</div><br>
									</div>
								</div>
							</li>
						</ul><!-- /.tabled-data -->

						<ul id="total-field" class="tabled-data inverse-bold ">
							<li>
								<label>订单总价</label>
								<div class="value"><?php echo $model->amount ?></div>
							</li>
						</ul><!-- /.tabled-data -->

					</div><!-- /#subtotal-holder -->
				</div><!-- /.col -->
			</div><!-- /#total-area -->

			<div id="payment-method-options">
				<form >
					<div class="payment-method-option">
						<!--<input class="le-radio" type="radio" name="group2" value="paypal">-->
						<div class="radio-label bold ">支付宝支付</div>
					</div><!-- /.payment-method-option -->
				</form>
			</div><!-- /#payment-method-options -->

			<div class="place-order-button">
				<div class="">
					<div class="form-group">
						<?php if ($model->status == 0) {
							?>
						<a href="<?php echo yii\helpers\Url::toRoute(['shop-order/pay','id'=>$model->orderId]); ?>"><button class="btn le-button big" style="'float: right">支付</button></a>
						<?php } ?>
					</div>
				</div>
				<!--<button name="submit" class="le-button big">提交订单</button>-->
			</div><!-- /.place-order-button -->

		</div><!-- /.col -->
	</div><!-- /.container -->    
</section><!-- /#checkout-page -->

<!-- ========================================= CONTENT : END ========================================= -->	
<script>
	function showAddressForm()
	{
		var addressForm = document.getElementById('billing-address');
		addressForm.style.display = 'block';
	}
	function hideAddressForm()
	{
		var addressForm = document.getElementById('billing-address');
		addressForm.style.display = 'none';
	}
//	function createOrder() {
////		alert('createOrder');
//		var iForm = document.getElementById('orderList');
//		var input = document.getElementById('addressId').value;
//		if (input == 0) {
//			alert("请先新建地址");
//		} else
//		{
//			iForm.submit();
//		}
//	}
	function setAddressId(addressId)
	{
		document.getElementById('addressId').value = addressId;
	}
</script>